package com.luowenbo.shortlink.separation.service.impl;

import com.luowenbo.shortlink.separation.annotation.HotCold;
import com.luowenbo.shortlink.separation.entity.UrlMap;
import com.luowenbo.shortlink.separation.mapper.UrlMapInHotMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.OffsetDateTime;
import java.util.List;
@Component
public class UrlMapInHotServiceImpl {

    @Autowired
    private UrlMapInHotMapper urlMapInHotMapper;

    @HotCold(value = "Hot")
    public int findColdDataCountInHot(OffsetDateTime time) {
        return urlMapInHotMapper.findColdDataCountInHot(time);
    }

    @HotCold(value = "Hot")
    public int updateColdFlagInHot(OffsetDateTime time) {
        return urlMapInHotMapper.updateColdFlagInHot(time);
    }

    @HotCold(value = "Hot")
    public int AtomicUpdateLockThread(String threadName, OffsetDateTime time) {
        return urlMapInHotMapper.AtomicUpdateLockThread(threadName, time);
    }

    @HotCold(value = "Hot")
    public List<UrlMap> getDataByThread(String threadName) {
        return urlMapInHotMapper.getDataByThread(threadName);
    }

    @HotCold(value = "Hot")
    public int deleteColdDataInHotDB(String threadName) {
        return urlMapInHotMapper.deleteColdDataInHotDB(threadName);
    }
}
